﻿using System;
using System.Collections.Generic;
using System.Text;

namespace 继承
{

    //记者：我是记者我的爱好是偷拍 我的年龄是34 我是一个男狗仔
    //司机：我叫老秦 我的年龄是43 我是男人 我的驾龄是23
    //程序员：我叫老饭 我的年龄是23 我是男生 我的工作年限是3年
    public class Progem//父类
    {
        public Progem(string name,int avg,char gender)
        {
            this.Name = name;
            this.Avg = avg;
            this.Gender = gender;
        }
        private string _name;
        public string Name//姓名
        {
            get{ 
                if(_name =="")
                {
                    _name = "**";
                }
                return _name; }
            set{ _name = value; }
        }
        private int _avg;//年龄
        public int Avg
        {
            get {
                
                return _avg; }
            set{
                if (value < 0 || value >= 100)
                {
                    value = 0;
                }
                _avg = value; }
            
        }
        private char _gender;//性别
        public char Gender
        {
            get { return _gender; }
            set {
                if (value != '男' && value != '女')
                {
                    value = '男';
                }
                _gender = value; }
        }
        
    }
    public class Jizhe:Progem//记者
    {
       public Jizhe (string name,int avg,char gender,string aihao) //构造函数
            : base(name,avg,gender)//调用父类的构造函数
        {
            this.Aihao = aihao;
        }
        private string _aihao;
        public string Aihao
        {
            get { return _aihao; }
            set { _aihao = value; }
        }
        public void aaa()
        {
            Console.WriteLine("我是{0}，我的爱好是{1},我今年{2}岁了，我是一个{3}狗仔", this.Name, this.Aihao, this.Avg, this.Gender);
        }
    }//记者
    public class Siji:Progem //司机
    {
        public Siji (string name,int avg,char gender,int jialing)
            :base(name, avg, gender)
        {
            this.Jialing = jialing;
        }
        private int _jialing;
        public int Jialing
        {
            get { return _jialing; }
            set { _jialing = value; }
        }
        public void bbb()
        {
            Console.WriteLine("我叫{0}，我的年龄{1},我是一个{2}人，我的驾龄是{3}年了",this.Name,this.Avg,this.Gender,this.Jialing);
        }

    }//司机
    public class Chengxuyuan:Progem
    {
        public Chengxuyuan (string name,int avg,char gender,int gznx) 
            : base(name, avg, gender)
        {
            this.Gznx = gznx;
        }
        private int _gznx;
        public int Gznx
        {
            get { return _gznx; }
            set { _gznx = value; }
        }
        public void ccc()
        {
            Console.WriteLine("我叫{0}，我的年龄是{1}，我是一个{2}生，我的工作年限是{3}年",this.Name,this.Avg,this.Gender,this.Gznx);
        }
    }//程序员
    public class Xiaofangyuan:Progem
    {
        public Xiaofangyuan(string name,int avg,char gender,string zeren) : base(name, avg, gender)
        {
            this.Zeren = zeren;
        }
        private string _zeren;
        public string Zeren
        {
            get { return _zeren; }
            set { _zeren = value; }
        }
        public void ddd()
        {
            Console.WriteLine("我是{0}，我今年{1}岁，我是一个{2}生，我的工作责任是{3}",this.Name,this.Avg,this.Gender,this.Zeren);
        }

    }//消防员
}
